package net.cyndeline.misc

/**
 * Stores elements that can be retrieved using indexes, without
 * the index of a particular elements changing when other elements
 * are added or removed.
 */
trait ImmutableBag[E] {
  
  def add(item: E)
  def get(index: Int): Option[E]
  def set(index: Int, item: E)
  
  /**
   * Removes the item at the specified index and replaces
   * it with the item at the end of the bag.
   */
  def remove(index: Int): Option[E]
  
  /**
   * Removes the last item in the bag.
   */
  def removeLast(): Option[E]
  
  /**
   * Number of elements in the bag.
   */
  def size: Int
  
  /**
   * Number of allocated space in the underlying implementation.
   */
  def capacity: Int
  
  def isEmpty: Boolean
  def clear()
  def contains(element: E): Boolean
}